﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using chessLogic;

namespace chessTest
{
    [TestFixture]
    class testFigureMove
    {
        private FigureMove move;
        private Board board;
        [SetUp]
        public void SetUp()
        {
            move = new FigureMove();
            board = new Board();
            board.InitialBoard();
        }
        [Test]
        public void testTrueMoveType()
        {
            move.ConvertNotation("e4",board, FigureColor.White);
            Assert.AreEqual(move.MovingType, MoveType.Normal);
            board.setFigure(new Position("e4"), new Pawn(FigureColor.White));
            board.setFigure(new Position("d4"), new Pawn(FigureColor.Black));
            move.ConvertNotation("dxe5",board, FigureColor.White);
            Assert.AreEqual(move.MovingType, MoveType.Passant);
        }
        [Test]
        public void testTrueMovingFigure()
        {
            move.setMovingFigure("e4", FigureColor.White);
            Assert.True(move.MovingFigure.Equals(new Pawn(FigureColor.White)));
            move.setMovingFigure("Be4", FigureColor.Black);
            Assert.True(move.MovingFigure.Equals(new Bishop(FigureColor.Black)));
        }
        [Test]
        public void testTrueMovingWhere()
        {
            move.ConvertNotation("Be4",board, FigureColor.White);
            Assert.AreEqual(move.MovingWhere.ToString(), "e4");
            move.setMovingWhere("e4Q");
            Assert.AreEqual(move.MovingWhere.ToString(), "e4");
            move.setMovingWhere("e4+");
            Assert.AreEqual(move.MovingWhere.ToString(), "e4");
        }
        [Test]
        public void testTruePromotionFigure()
        {
            move.setMovingFigurePromotion("e4Q", FigureColor.White);
            Assert.True(new Queen(FigureColor.White).Equals(move.MovingFigurePromotion));
            move.setMovingFigurePromotion("e4R", FigureColor.White);
            Assert.True(new Rook(FigureColor.White).Equals(move.MovingFigurePromotion));
        }
        [Test]
        public void testTrueAdditChar()
        {
            move.setMovingAdditChar("dxe4");
            Assert.AreEqual('d', move.MovingAdditChar);
            move.setMovingAdditChar("R1xe4");
            Assert.AreEqual('1', move.MovingAdditChar);
        }
    }
}
